#ifdef Q_OS_WIN
// Ensure OpenSSL config file is only loaded from app directory
- QString opensslConf = QCoreApplication::applicationDirPath() + QString("/openssl.cnf");
+ QString opensslConf = QCoreApplication::applicationDirPath() + QStringLiteral("/openssl.cnf");
qputenv("OPENSSL_CONF", opensslConf.toLocal8Bit());
#endif
#ifdef Q_OS_WIN
// Ensure OpenSSL config file is only loaded from app directory
- QString opensslConf = QCoreApplication::applicationDirPath() + QString("/openssl.cnf");
+ QString opensslConf = QCoreApplication::applicationDirPath() + QStringLiteral("/openssl.cnf");
qputenv("OPENSSL_CONF", opensslConf.toLocal8Bit());
#endif
{
GMenuModel *model = nullptr;
GActionGroup *action_group = nullptr;
- QString accountName = QString("Folder/%1").arg(folderId);
+ QString accountName = QStringLiteral("Folder/%1").arg(folderId);
_cloudProvider = CLOUD_PROVIDERS_PROVIDER_EXPORTER(cloudprovider);
_cloudProviderAccount = cloud_providers_account_exporter_new(_cloudProvider, accountName.toUtf8().data());
void CloudProviderWrapper::updateStatusText(QString statusText)
{
- QString status = QString("%1 - %2").arg(_folder->accountState()->stateString(_folder->accountState()->state()), statusText);
+ QString status = QStringLiteral("%1 - %2").arg(_folder->accountState()->stateString(_folder->accountState()->state()), statusText);
cloud_providers_account_exporter_set_status_details(_cloudProviderAccount, status.toUtf8().data());
}
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
auto requestBody = new QBuffer;
- QUrlQuery arguments(QString("token=%1").arg(_pollToken));
+ QUrlQuery arguments(QStringLiteral("token=%1").arg(_pollToken));
requestBody->setData(arguments.query(QUrl::FullyEncoded).toLatin1());
auto job = _account->sendRequest("POST", _pollEndpoint, req, requestBody);
const auto provider = QStringLiteral("image://tray-image-provider/");
const auto userId = share->getShareWith()->shareWith();
const auto avatarUrl = Utility::concatUrlPath(_accountState->account()->url(),
- QString("remote.php/dav/avatars/%1/%2.png").arg(userId, QString::number(64))).toString();
+ QStringLiteral("remote.php/dav/avatars/%1/%2.png").arg(userId, QString::number(64))).toString();
return QString(provider + avatarUrl);
}
static const QRegularExpression lowercaseMatch("[a-z]");
static const QRegularExpression uppercaseMatch("[A-Z]");
static const QRegularExpression numberMatch("[0-9]");
- static const QRegularExpression specialCharMatch(QString("[%1]").arg(specialChars.data()));
+ static const QRegularExpression specialCharMatch(QStringLiteral("[%1]").arg(specialChars.data()));
static const std::map<std::string_view, QRegularExpression> matchMap{
{lowercaseAlphabet, lowercaseMatch},
ui->newFolderNameEdit->setText(suggestedFolderNamePrefix);
} else {
for (unsigned int i = 2; i < std::numeric_limits<unsigned int>::max(); ++i) {
- const QString suggestedPostfix = QString(" (%1)").arg(i);
+ const QString suggestedPostfix = QStringLiteral(" (%1)").arg(i);
if (!QDir(newFolderFullPath + suggestedPostfix).exists()) {
ui->newFolderNameEdit->setText(suggestedFolderNamePrefix + suggestedPostfix);
case Qt::DisplayRole:
if (folderInfo->_hasError) {
return {tr("Error while loading the list of folders from the server.")
- + QString("\n")
+ + QStringLiteral("\n")
+ folderInfo->_lastErrorString};
} else {
return tr("Fetching folder list from server …");
setVerb("GET");
addParam(QString::fromLatin1("path"), path);
- addParam(QString::fromLatin1("reshares"), QString("true"));
- addParam(QString::fromLatin1("shared_with_me"), QString("true"));
+ addParam(QString::fromLatin1("reshares"), QStringLiteral("true"));
+ addParam(QString::fromLatin1("shared_with_me"), QStringLiteral("true"));
for (auto it = std::cbegin(params); it != std::cend(params); ++it) {
addParam(it.key(), it.value());
request.setUrl(requestUrl);
request.setSslConfiguration(_account->getOrCreateSslConfig());
auto requestBody = new QBuffer;
- QUrlQuery arguments(QString("token=%1").arg(_appPassword));
+ QUrlQuery arguments(QStringLiteral("token=%1").arg(_appPassword));
requestBody->setData(arguments.query(QUrl::FullyEncoded).toLatin1());
_networkReplyCheck = _networkManager.post(request, requestBody);
QObject::connect(&_networkManager, &QNetworkAccessManager::sslErrors,
jsonParseError.error != QJsonParseError::NoError) {
QString errorFromJson = json["error"].toString();
if (!errorFromJson.isEmpty()) {
- qCWarning(lcRemoteWipe) << QString("Error returned from the server: <em>%1<em>")
+ qCWarning(lcRemoteWipe) << QStringLiteral("Error returned from the server: <em>%1<em>")
.arg(errorFromJson.toHtmlEscaped());
} else if (_networkReplyCheck->error() != QNetworkReply::NoError) {
- qCWarning(lcRemoteWipe) << QString("There was an error accessing the 'token' endpoint: <br><em>%1</em>")
+ qCWarning(lcRemoteWipe) << QStringLiteral("There was an error accessing the 'token' endpoint: <br><em>%1</em>")
.arg(_networkReplyCheck->errorString().toHtmlEscaped());
} else if (jsonParseError.error != QJsonParseError::NoError) {
- qCWarning(lcRemoteWipe) << QString("Could not parse the JSON returned from the server: <br><em>%1</em>")
+ qCWarning(lcRemoteWipe) << QStringLiteral("Could not parse the JSON returned from the server: <br><em>%1</em>")
.arg(jsonParseError.errorString());
} else {
- qCWarning(lcRemoteWipe) << QString("The reply from the server did not contain all expected fields");
+ qCWarning(lcRemoteWipe) << QStringLiteral("The reply from the server did not contain all expected fields");
}
// check for wipe request
request.setUrl(requestUrl);
request.setSslConfiguration(_account->getOrCreateSslConfig());
auto requestBody = new QBuffer;
- QUrlQuery arguments(QString("token=%1").arg(_appPassword));
+ QUrlQuery arguments(QStringLiteral("token=%1").arg(_appPassword));
requestBody->setData(arguments.query(QUrl::FullyEncoded).toLatin1());
_networkReplySuccess = _networkManager.post(request, requestBody);
QObject::connect(_networkReplySuccess, &QNetworkReply::finished, this,
jsonParseError.error != QJsonParseError::NoError) {
QString errorFromJson = json["error"].toString();
if (!errorFromJson.isEmpty()) {
- qCWarning(lcRemoteWipe) << QString("Error returned from the server: <em>%1</em>")
+ qCWarning(lcRemoteWipe) << QStringLiteral("Error returned from the server: <em>%1</em>")
.arg(errorFromJson.toHtmlEscaped());
} else if (_networkReplySuccess->error() != QNetworkReply::NoError) {
- qCWarning(lcRemoteWipe) << QString("There was an error accessing the 'success' endpoint: <br><em>%1</em>")
+ qCWarning(lcRemoteWipe) << QStringLiteral("There was an error accessing the 'success' endpoint: <br><em>%1</em>")
.arg(_networkReplySuccess->errorString().toHtmlEscaped());
} else if (jsonParseError.error != QJsonParseError::NoError) {
- qCWarning(lcRemoteWipe) << QString("Could not parse the JSON returned from the server: <br><em>%1</em>")
+ qCWarning(lcRemoteWipe) << QStringLiteral("Could not parse the JSON returned from the server: <br><em>%1</em>")
.arg(jsonParseError.errorString());
} else {
- qCWarning(lcRemoteWipe) << QString("The reply from the server did not contain all expected fields.");
+ qCWarning(lcRemoteWipe) << QStringLiteral("The reply from the server did not contain all expected fields.");
}
}
{ "EMAIL_PRIVATE_LINK_MENU_TITLE", tr("Send private link by email …") },
{ "CONTEXT_MENU_ICON", APPLICATION_ICON_NAME },
} };
- listener->sendMessage(QString("GET_STRINGS:BEGIN"));
+ listener->sendMessage(QStringLiteral("GET_STRINGS:BEGIN"));
for (const auto& key_value : strings) {
if (argument.isEmpty() || argument == QLatin1String(key_value.first)) {
- listener->sendMessage(QString("STRING:%1:%2").arg(key_value.first, key_value.second));
+ listener->sendMessage(QStringLiteral("STRING:%1:%2").arg(key_value.first, key_value.second));
}
}
- listener->sendMessage(QString("GET_STRINGS:END"));
+ listener->sendMessage(QStringLiteral("GET_STRINGS:END"));
}
void SocketApi::sendSharingContextMenuOptions(const FileData &fileData, SocketListener *listener, SharingContextItemEncryptedFlag itemEncryptionFlag, SharingContextItemRootEncryptedFolderFlag rootE2eeFolderFlag)
void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListener *listener)
{
- listener->sendMessage(QString("GET_MENU_ITEMS:BEGIN"), true);
+ listener->sendMessage(QStringLiteral("GET_MENU_ITEMS:BEGIN"), true);
const QStringList files = split(argument);
// Find the common sync folder.
}
}
- listener->sendMessage(QString("GET_MENU_ITEMS:END"));
+ listener->sendMessage(QStringLiteral("GET_MENU_ITEMS:END"));
}
DirectEditor* SocketApi::getDirectEditorForLocalFile(const QString &localFile)
if(QString::compare(folderPath,line,Qt::CaseSensitive)!=0) {
depthIndex++;
if(depthIndex <= length) {
- filenameSingle = folderPath.split(QLatin1String("/")).at(length - depthIndex) + QString("_") ///
+ filenameSingle = folderPath.split(QLatin1String("/")).at(length - depthIndex) + QStringLiteral("_") ///
+ filenameSingle;
filename = logpath+ QLatin1String("/") + filenameSingle + QLatin1String("_sync.log");
}
&UnifiedSearchResultsListModel::slotSearchTermEditingFinished);
if (!_accountState || !_accountState->account()) {
- qCCritical(lcUnifiedSearch) << QString("Account state is invalid. Could not start search!");
+ qCCritical(lcUnifiedSearch) << QStringLiteral("Account state is invalid. Could not start search!");
return;
}
const auto job = qobject_cast<JsonApiJob *>(sender());
if (!job) {
- qCCritical(lcUnifiedSearch) << QString("Failed to fetch providers.").arg(_searchTerm);
+ qCCritical(lcUnifiedSearch) << QStringLiteral("Failed to fetch providers.").arg(_searchTerm);
_errorString += tr("Failed to fetch providers.") + QLatin1Char('\n');
emit errorStringChanged();
return;
}
if (statusCode != 200) {
- qCCritical(lcUnifiedSearch) << QString("%1: Failed to fetch search providers for '%2'. Error: %3")
+ qCCritical(lcUnifiedSearch) << QStringLiteral("%1: Failed to fetch search providers for '%2'. Error: %3")
.arg(statusCode)
.arg(_searchTerm)
.arg(job->errorString());
const auto job = qobject_cast<JsonApiJob *>(sender());
if (!job) {
- qCCritical(lcUnifiedSearch) << QString("Search has failed for '%2'.").arg(_searchTerm);
+ qCCritical(lcUnifiedSearch) << QStringLiteral("Search has failed for '%2'.").arg(_searchTerm);
_errorString += tr("Search has failed for '%2'.").arg(_searchTerm) + QLatin1Char('\n');
emit errorStringChanged();
return;
}
if (statusCode != 200) {
- qCCritical(lcUnifiedSearch) << QString("%1: Search has failed for '%2'. Error: %3")
+ qCCritical(lcUnifiedSearch) << QStringLiteral("%1: Search has failed for '%2'. Error: %3")
.arg(statusCode)
.arg(_searchTerm)
.arg(job->errorString());
};
QString msiLogFile = cfg.configPath() + "msi.log";
- QString command = QString("&{msiexec /i '%1' /L*V '%2'| Out-Null ; &'%3'}")
+ QString command = QStringLiteral("&{msiexec /i '%1' /L*V '%2'| Out-Null ; &'%3'}")
.arg(preparePathForPowershell(updateFile))
.arg(preparePathForPowershell(msiLogFile))
.arg(preparePathForPowershell(QCoreApplication::applicationFilePath()));
if (const auto result = doc.setContent(xml); !result) {
qCWarning(lcUpdater).noquote().nospace() << result.errorMessage << " at " << result.errorLine << "," << result.errorColumn
<< "\n" << xml.split("\n").value(result.errorLine - 1) << "\n"
- << QString(" ").repeated(result.errorColumn - 1) << "^\n"
+ << QStringLiteral(" ").repeated(result.errorColumn - 1) << "^\n"
<< "->" << xml << "<-";
if (ok)
*ok = false;
_statusUpdateSkipCount--;
break;
}
- _ui.statusLabel->setText(tr("Waiting for authorization") + QString("… (%1)").arg(secondsLeft));
+ _ui.statusLabel->setText(tr("Waiting for authorization") + QStringLiteral("… (%1)").arg(secondsLeft));
stopSpinner(true);
break;
case Flow2Auth::statusPollNow:
_ui->slideShow->addSlide(wizardTalkIconFileName, tr("Screensharing, online meetings & web conferences"));
const auto isDarkBackground = Theme::isDarkColor(backgroundColor);
- _ui->slideShowNextButton->setIcon(theme->uiThemeIcon(QString("control-next.svg"), isDarkBackground));
- _ui->slideShowPreviousButton->setIcon(theme->uiThemeIcon(QString("control-prev.svg"), isDarkBackground));
+ _ui->slideShowNextButton->setIcon(theme->uiThemeIcon(QStringLiteral("control-next.svg"), isDarkBackground));
+ _ui->slideShowPreviousButton->setIcon(theme->uiThemeIcon(QStringLiteral("control-prev.svg"), isDarkBackground));
}
void WelcomePage::setupSlideShow()
_timer.start();
const QUrl url = account()->url();
- const QString displayUrl = QString("%1://%2%3").arg(url.scheme()).arg(url.host()).arg(url.path());
+ const QString displayUrl = QStringLiteral("%1://%2%3").arg(url.scheme()).arg(url.host()).arg(url.path());
QString parentMetaObjectName = parent() ? parent()->metaObject()->className() : "";
qCInfo(lcNetworkJob) << metaObject()->className() << "created for" << displayUrl << "+" << path() << parentMetaObjectName;
credentialsUser = _credentials->user();
}
- auto displayName = QString("%1@%2").arg(credentialsUser, _url.host());
+ auto displayName = QStringLiteral("%1@%2").arg(credentialsUser, _url.host());
const auto port = url().port();
if (port > 0 && port != 80 && port != 443) {
displayName.append(QLatin1Char(':'));
QString ClientProxy::printQNetworkProxy(const QNetworkProxy &proxy)
{
- return QString("%1://%2:%3").arg(proxyTypeToCStr(proxy.type())).arg(proxy.hostName()).arg(proxy.port());
+ return QStringLiteral("%1://%2:%3").arg(proxyTypeToCStr(proxy.type())).arg(proxy.hostName()).arg(proxy.port());
}
void ClientProxy::setupQtProxyFromConfig()
}
QString backupFile =
- QString("%1.backup_%2%3")
+ QStringLiteral("%1.backup_%2%3")
.arg(baseFilePath)
.arg(QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss"))
.arg(versionString);
return;
}
- const QString keyWithIndex = _key + (index > 0 ? (QString(".") + QString::number(index)) : QString());
+ const QString keyWithIndex = _key + (index > 0 ? (QStringLiteral(".") + QString::number(index)) : QString());
const QString kck = _account ? AbstractCredentials::keychainKey(
_account->url().toString(),
keyWithIndex,
#if defined(Q_OS_WIN)
// try to fetch next chunk
if (_chunkCount < KeychainChunk::MaxChunks) {
- const QString keyWithIndex = _key + QString(".") + QString::number(_chunkCount);
+ const QString keyWithIndex = _key + QStringLiteral(".") + QString::number(_chunkCount);
const QString kck = _account ? AbstractCredentials::keychainKey(
_account->url().toString(),
keyWithIndex,
#if defined(Q_OS_WIN)
// try to delete next chunk
if (_chunkCount < KeychainChunk::MaxChunks) {
- const QString keyWithIndex = _key + QString(".") + QString::number(_chunkCount);
+ const QString keyWithIndex = _key + QStringLiteral(".") + QString::number(_chunkCount);
const QString kck = _account ? AbstractCredentials::keychainKey(
_account->url().toString(),
keyWithIndex,
if (containsForbiddenCharacters) {
reasonString = tr("Reason: the filename contains a forbidden character (%1).").arg(forbiddenCharMatch);
}
- item->_errorString = reasonString.isEmpty() ? errorString : QString("%1 %2").arg(errorString, reasonString);
+ item->_errorString = reasonString.isEmpty() ? errorString : QStringLiteral("%1 %2").arg(errorString, reasonString);
item->_status = SyncFileItem::FileNameInvalidOnServer;
break;
}
: AbstractNetworkJob(account, QString(), parent)
{
if (account->serverVersionInt() >= Account::makeServerVersion(10, 0, 0)) {
- _avatarUrl = Utility::concatUrlPath(account->url(), QString("remote.php/dav/avatars/%1/%2.png").arg(userId, QString::number(size)));
+ _avatarUrl = Utility::concatUrlPath(account->url(), QStringLiteral("remote.php/dav/avatars/%1/%2.png").arg(userId, QString::number(size)));
} else {
- _avatarUrl = Utility::concatUrlPath(account->url(), QString("index.php/avatar/%1/%2").arg(userId, QString::number(size)));
+ _avatarUrl = Utility::concatUrlPath(account->url(), QStringLiteral("index.php/avatar/%1/%2").arg(userId, QString::number(size)));
}
}
QString NextcloudTheme::wizardUrlHint() const
{
- return QString("https://try.nextcloud.com");
+ return QStringLiteral("https://try.nextcloud.com");
}
}
int chownErr = chown(fileName.toLocal8Bit().constData(), -1, fi.groupId());
if (chownErr) {
// TODO: Consider further error handling!
- qCWarning(lcPropagateDownload) << QString("preserveGroupOwnership: chown error %1: setting group %2 failed on file %3").arg(chownErr).arg(fi.groupId()).arg(fileName);
+ qCWarning(lcPropagateDownload) << QStringLiteral("preserveGroupOwnership: chown error %1: setting group %2 failed on file %3").arg(chownErr).arg(fi.groupId()).arg(fileName);
}
#else
Q_UNUSED(fileName);
emit propagator()->touchedFile(filename);
// The fileChanged() check is done above to generate better error messages.
if (!FileSystem::uncheckedRenameReplace(_tmpFile.fileName(), filename, &error)) {
- qCWarning(lcPropagateDownload) << QString("Rename failed: %1 => %2").arg(_tmpFile.fileName()).arg(filename);
+ qCWarning(lcPropagateDownload) << QStringLiteral("Rename failed: %1 => %2").arg(_tmpFile.fileName()).arg(filename);
// If the file is locked, we want to retry this sync when it
// becomes available again, otherwise try again directly
if (FileSystem::isFileLocked(filename)) {
constexpr auto maxChunkDigits = 5; // Chunk V2: max num of chunks is 10000
// We need to do add leading 0 because the server orders the chunk alphabetically
- const auto chunkNumString = QString("%1").arg(chunk, maxChunkDigits, 10, QChar('0'));
+ const auto chunkNumString = QStringLiteral("%1").arg(chunk, maxChunkDigits, 10, QChar('0'));
return Utility::concatUrlPath(chunkUploadFolderUrl(), chunkNumString);
}
// XOR with chunk size to make sure everything goes well if chunk size changes between runs
uint transid = _transferId ^ uint(chunkSize());
qCInfo(lcPropagateUploadV1) << "Upload chunk" << sendingChunk << "of" << _chunkCount << "transferid(remote)=" << transid;
- path += QString("-chunking-%1-%2-%3").arg(transid).arg(_chunkCount).arg(sendingChunk);
+ path += QStringLiteral("-chunking-%1-%2-%3").arg(transid).arg(_chunkCount).arg(sendingChunk);
headers[QByteArrayLiteral("OC-Chunked")] = QByteArrayLiteral("1");
// syncRootId should be: [storage provider ID]![Windows SID]![Account ID]![FolderAlias] (FolderAlias is a custom part added here to be able to register multiple sync folders for the same account)
// folder registry keys go like: Nextcloud!S-1-5-21-2096452760-2617351404-2281157308-1001!user@nextcloud.lan:8080!0, Nextcloud!S-1-5-21-2096452760-2617351404-2281157308-1001!user@nextcloud.lan:8080!1, etc. for each sync folder
- const auto syncRootId = QString("%1!%2!%3!%4").arg(providerName).arg(windowsSid).arg(accountDisplayName).arg(folderAlias);
+ const auto syncRootId = QStringLiteral("%1!%2!%3!%4").arg(providerName).arg(windowsSid).arg(accountDisplayName).arg(folderAlias);
const QString providerSyncRootIdRegistryKey = syncRootManagerRegKey + QStringLiteral("\\") + syncRootId;
const QString providerSyncRootIdUserSyncRootsRegistryKey = providerSyncRootIdRegistryKey + QStringLiteral(R"(\UserSyncRoots\)");
return false;
}
- const auto currentUserSyncRootIdPattern = QString("%1!%2!%3").arg(providerName).arg(windowsSid).arg(accountDisplayName);
+ const auto currentUserSyncRootIdPattern = QStringLiteral("%1!%2!%3").arg(providerName).arg(windowsSid).arg(accountDisplayName);
bool result = true;
return;
}
- const auto syncRootId = QString("%1!%2!%3!%4").arg(providerName).arg(windowsSid).arg(accountDisplayName).arg(folderAlias);
+ const auto syncRootId = QStringLiteral("%1!%2!%3!%4").arg(providerName).arg(windowsSid).arg(accountDisplayName).arg(folderAlias);
const QString providerSyncRootIdRegistryKey = syncRootManagerRegKey + QStringLiteral("\\") + syncRootId;
return false;
}
- const auto syncRootPrefix = QString("%1!%2!%3!").arg(providerName).arg(windowsSid).arg(accountDisplayName);
+ const auto syncRootPrefix = QStringLiteral("%1!%2!%3!").arg(providerName).arg(windowsSid).arg(accountDisplayName);
if (Utility::registryKeyExists(HKEY_LOCAL_MACHINE, syncRootManagerRegKey)) {
bool foundSyncRoots = false;
winrt::Windows::Storage::Provider::StorageProviderItemProperty itemProperty;
itemProperty.Id(stateValue);
- itemProperty.Value(QString("Value%1").arg(stateValue).toStdWString());
- itemProperty.IconResource(QString(_dllFilePath + QString(",%1").arg(QString::number(stateValue))).toStdWString());
+ itemProperty.Value(QStringLiteral("Value%1").arg(stateValue).toStdWString());
+ itemProperty.IconResource(QString(_dllFilePath + QStringLiteral(",%1").arg(QString::number(stateValue))).toStdWString());
properties.push_back(std::move(itemProperty));
}
}
QString fn = _setupParams.filesystemPath + item._file;
if (!fn.endsWith(fileSuffix())) {
ASSERT(false, "vfs file isn't ending with suffix");
- return QString("vfs file isn't ending with suffix");
+ return QStringLiteral("vfs file isn't ending with suffix");
}
QFile file(fn);
if (file.exists() && file.size() > 1
&& !FileSystem::verifyFileUnchanged(fn, item._size, item._modtime)) {
- return QString("Cannot create a placeholder because a file with the placeholder name already exist");
+ return QStringLiteral("Cannot create a placeholder because a file with the placeholder name already exist");
}
if (!file.open(QFile::ReadWrite | QFile::Truncate))
// QTest::toString overloads
namespace OCC {
inline char *toString(const SyncFileStatus &s) {
- return QTest::toString(QString("SyncFileStatus(" + s.toSocketAPIString() + ")"));
+ return QTest::toString(QStringLiteral("SyncFileStatus(%1)").arg(s.toSocketAPIString()));
}
}
inline void addFiles(QStringList &dest, const FileInfo &fi)
{
if (fi.isDir) {
- dest += QString("%1 - dir").arg(fi.path());
+ dest += QStringLiteral("%1 - dir").arg(fi.path());
foreach (const FileInfo &fi, fi.children)
addFiles(dest, fi);
} else {
- dest += QString("%1 - %2 %3-bytes").arg(fi.path()).arg(fi.size).arg(fi.contentChar);
+ dest += QStringLiteral("%1 - %2 %3-bytes").arg(fi.path()).arg(fi.size).arg(fi.contentChar);
}
}
foreach (const FileInfo &fi, fi.children)
addFiles(files, fi);
files.sort();
- return QString("FileInfo with %1 files(\n\t%2\n)").arg(files.size()).arg(files.join("\n\t"));
+ return QStringLiteral("FileInfo with %1 files(\n\t%2\n)").arg(files.size()).arg(files.join("\n\t"));
}
inline char *toString(const FileInfo &fi)
{
// could include etag, permissions etc, but would need extra work
if (fi.isDir) {
- dest += QString("%1 - %2 %3 %4").arg(
+ dest += QStringLiteral("%1 - %2 %3 %4").arg(
fi.name,
fi.isDir ? "dir" : "file",
QString::number(fi.lastModified.toSecsSinceEpoch()),
foreach (const FileInfo &fi, fi.children)
addFilesDbData(dest, fi);
} else {
- dest += QString("%1 - %2 %3 %4 %5").arg(
+ dest += QStringLiteral("%1 - %2 %3 %4 %5").arg(
fi.name,
fi.isDir ? "dir" : "file",
QString::number(fi.size),
QStringList files;
foreach (const FileInfo &fi, fi.children)
addFilesDbData(files, fi);
- return QTest::toString(QString("FileInfo with %1 files(%2)").arg(files.size()).arg(files.join(", ")));
+ return QTest::toString(QStringLiteral("FileInfo with %1 files(%2)").arg(files.size()).arg(files.join(", ")));
}
std::thread t1([&] {
VfsShellExtensions::ThumbnailProviderIpc thumbnailProviderIpc;
thumbnailReplyData = thumbnailProviderIpc.fetchThumbnailForFile(
- fakeFolder.localPath() + QString("A/photos/wrong.jpg"), QSize(256, 256));
+ fakeFolder.localPath() + QStringLiteral("A/photos/wrong.jpg"), QSize(256, 256));
QMetaObject::invokeMethod(&loop, &QEventLoop::quit, Qt::QueuedConnection);
});
loop.exec();
const auto chunkingId = fakeFolder.uploadState().children.first().name;
const auto chunkMap = fakeFolder.uploadState().children.first().children;
const auto firstChunkName = chunkMap.first().name;
- const auto expectedChunkName = QString("%1").arg(1, 5, 10, QChar('0'));
+ const auto expectedChunkName = QStringLiteral("%1").arg(1, 5, 10, QChar('0'));
QCOMPARE(firstChunkName, expectedChunkName);
}
// Add a chunk that makes the file completely uploaded
const auto testChunkNameNum = chunkMap.count() + 1; // Chunk nums start at 1 with Chunk V2, so size() == last num, add 1
- const auto testChunkName = QString("%1").arg(testChunkNameNum, 5, 10, QChar('0'));
+ const auto testChunkName = QStringLiteral("%1").arg(testChunkNameNum, 5, 10, QChar('0'));
const auto testChunkSize = size - uploadedSize;
fakeFolder.uploadState().children.first().insert(testChunkName, testChunkSize);
// Add a chunk that makes the file more than completely uploaded
const auto testChunkNameNum = chunkMap.count() + 1; // Chunk nums start at 1 with Chunk V2, so size() == last num, add 1
- const auto testChunkName = QString("%1").arg(testChunkNameNum, 5, 10, QChar('0'));
+ const auto testChunkName = QStringLiteral("%1").arg(testChunkNameNum, 5, 10, QChar('0'));
const auto testChunkSize = size - uploadedSize + 100;
fakeFolder.uploadState().children.first().insert(testChunkName, testChunkSize);
QVERIFY(!fakeFolder.syncOnce()); // The sync must fail because not all the file was downloaded
QCOMPARE(getItem(completeSpy, "A/a0")->_status, SyncFileItem::SoftError);
- QCOMPARE(getItem(completeSpy, "A/a0")->_errorString, QString("The file could not be downloaded completely."));
+ QCOMPARE(getItem(completeSpy, "A/a0")->_errorString, QStringLiteral("The file could not be downloaded completely."));
QVERIFY(fakeFolder.syncEngine().isAnotherSyncNeeded());
// Now, we need to restart, this time, it should resume.
void testAddExcludeFilePath_addSameFilePath_listSizeDoesNotIncrease()
{
excludedFiles.reset(new ExcludedFiles());
- const auto filePath = QString("exclude/.sync-exclude.lst");
+ const auto filePath = QStringLiteral("exclude/.sync-exclude.lst");
excludedFiles->addExcludeFilePath(filePath);
excludedFiles->addExcludeFilePath(filePath);
{
excludedFiles.reset(new ExcludedFiles());
- const auto filePath1 = QString("exclude1/.sync-exclude.lst");
- const auto filePath2 = QString("exclude2/.sync-exclude.lst");
+ const auto filePath1 = QStringLiteral("exclude1/.sync-exclude.lst");
+ const auto filePath2 = QStringLiteral("exclude2/.sync-exclude.lst");
excludedFiles->addExcludeFilePath(filePath1);
excludedFiles->addExcludeFilePath(filePath2);
OCC::Utility::writeRandomFile(file);
#else
QString cmd;
- cmd = QString("touch %1").arg(file);
+ cmd = QStringLiteral("touch %1").arg(file);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
#endif
QDir dir;
dir.mkdir(file);
#else
- QString cmd = QString("mkdir %1").arg(file);
+ QString cmd = QStringLiteral("mkdir %1").arg(file);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
#endif
QDir dir;
dir.rmdir(file);
#else
- QString cmd = QString("rmdir %1").arg(file);
+ QString cmd = QStringLiteral("rmdir %1").arg(file);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
#endif
#ifdef Q_OS_WIN
QFile::remove(file);
#else
- QString cmd = QString("rm %1").arg(file);
+ QString cmd = QStringLiteral("rm %1").arg(file);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
#endif
#ifdef Q_OS_WIN
QFile::rename(file1, file2);
#else
- QString cmd = QString("mv %1 %2").arg(file1, file2);
+ QString cmd = QStringLiteral("mv %1 %2").arg(file1, file2);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
#endif
void testACreate() { // create a new file
QString file(_rootPath + "/foo.txt");
QString cmd;
- cmd = QString("echo \"xyz\" > \"%1\"").arg(file);
+ cmd = QStringLiteral("echo \"xyz\" > \"%1\"").arg(file);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
void cleanupTestCase() {
if( _root.startsWith(QDir::tempPath() )) {
- system( QString("rm -rf %1").arg(_root).toLocal8Bit() );
+ system( QStringLiteral("rm -rf %1").arg(_root).toLocal8Bit() );
}
}
};
fakeFolder.syncEngine().account()->setCapabilities({{"files", QVariantMap{{"locking", QByteArray{"1.0"}}}}});
QSignalSpy lockFileDetectedNewlyUploadedSpy(&fakeFolder.syncEngine(), &OCC::SyncEngine::lockFileDetected);
- fakeFolder.localModifier().insert(testDocumentsDirName + QString("/") + testLockFileName);
- fakeFolder.localModifier().insert(testDocumentsDirName + QString("/") + testFileName);
+ fakeFolder.localModifier().insert(testDocumentsDirName + QStringLiteral("/") + testLockFileName);
+ fakeFolder.localModifier().insert(testDocumentsDirName + QStringLiteral("/") + testFileName);
QVERIFY(fakeFolder.syncOnce());
void testValidNetrc() {
NetrcParser parser(testfileC);
QVERIFY(parser.parse());
- QCOMPARE(parser.find("foo"), qMakePair(QString("bar"), QString("baz")));
- QCOMPARE(parser.find("broken"), qMakePair(QString("bar2"), QString()));
- QCOMPARE(parser.find("funnysplit"), qMakePair(QString("bar3"), QString("baz3")));
+ QCOMPARE(parser.find("foo"), qMakePair(QStringLiteral("bar"), QStringLiteral("baz")));
+ QCOMPARE(parser.find("broken"), qMakePair(QStringLiteral("bar2"), QString()));
+ QCOMPARE(parser.find("funnysplit"), qMakePair(QStringLiteral("bar3"), QStringLiteral("baz3")));
QEXPECT_FAIL("", "Current implementation do not support spaces in username or password", Continue);
- QCOMPARE(parser.find("frob"), qMakePair(QString("user with spaces"), QString("space pwd")));
+ QCOMPARE(parser.find("frob"), qMakePair(QStringLiteral("user with spaces"), QStringLiteral("space pwd")));
}
void testEmptyNetrc() {
void testValidNetrcWithDefault() {
NetrcParser parser(testfileWithDefaultC);
QVERIFY(parser.parse());
- QCOMPARE(parser.find("foo"), qMakePair(QString("bar"), QString("baz")));
- QCOMPARE(parser.find("dontknow"), qMakePair(QString("user"), QString("pass")));
+ QCOMPARE(parser.find("foo"), qMakePair(QStringLiteral("bar"), QStringLiteral("baz")));
+ QCOMPARE(parser.find("dontknow"), qMakePair(QStringLiteral("user"), QStringLiteral("pass")));
}
void testInvalidNetrc() {
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(newBigFolder.count(), 1);
- QCOMPARE(newBigFolder.first()[0].toString(), QString("A/newBigDir"));
+ QCOMPARE(newBigFolder.first()[0].toString(), QStringLiteral("A/newBigDir"));
QCOMPARE(newBigFolder.first()[1].toBool(), false);
newBigFolder.clear();
auto oldSync = fakeFolder.currentLocalState();
// syncing again should do the same
- fakeFolder.syncEngine().journal()->schedulePathForRemoteDiscovery(QString("A/newBigDir"));
+ fakeFolder.syncEngine().journal()->schedulePathForRemoteDiscovery(QStringLiteral("A/newBigDir"));
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(fakeFolder.currentLocalState(), oldSync);
QCOMPARE(newBigFolder.count(), 1); // (since we don't have a real Folder, the files were not added to any list)
// Simulate that we accept all files by setting a wildcard white list
fakeFolder.syncEngine().journal()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList,
QStringList() << QLatin1String("/"));
- fakeFolder.syncEngine().journal()->schedulePathForRemoteDiscovery(QString("A/newBigDir"));
+ fakeFolder.syncEngine().journal()->schedulePathForRemoteDiscovery(QStringLiteral("A/newBigDir"));
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(newBigFolder.count(), 0);
QCOMPARE(sizeRequests.count(), 0);
// Check correct user avatar
const auto avatarUrl = shareIndex.data(ShareModel::AvatarUrlRole).toString();
- const auto relativeAvatarPath = QString("remote.php/dav/avatars/%1/%2.png").arg(_testUserShareDefinition.shareShareWith, QString::number(64));
+ const auto relativeAvatarPath = QStringLiteral("remote.php/dav/avatars/%1/%2.png").arg(_testUserShareDefinition.shareShareWith, QString::number(64));
const auto expectedAvatarPath = Utility::concatUrlPath(helper.account->url(), relativeAvatarPath).toString();
const QString expectedUrl(QStringLiteral("image://tray-image-provider/") + expectedAvatarPath);
QCOMPARE(avatarUrl, expectedUrl);
QCOMPARE(Utility::conflictFileBaseNameFromPattern(conflictMap[a1FileId].toUtf8()), QByteArray("A/a1"));
// Check that the conflict file contains the username
- QVERIFY(conflictMap[a1FileId].contains(QString("(conflicted copy %1 ").arg(fakeFolder.syncEngine().account()->davDisplayName())));
+ QVERIFY(conflictMap[a1FileId].contains(QStringLiteral("(conflicted copy %1 ").arg(fakeFolder.syncEngine().account()->davDisplayName())));
QCOMPARE(remote.find(conflictMap[a1FileId])->contentChar, 'L');
QCOMPARE(remote.find("A/a1")->contentChar, 'R');
// Begin Test mismatch recalculation---------------------------------------------------------------------------------
const auto prevServerVersion = fakeFolder.account()->serverVersion();
- fakeFolder.account()->setServerVersion(QString("%1.0.0").arg(fakeFolder.account()->checksumRecalculateServerVersionMinSupportedMajor()));
+ fakeFolder.account()->setServerVersion(QStringLiteral("%1.0.0").arg(fakeFolder.account()->checksumRecalculateServerVersionMinSupportedMajor()));
// Mismatched OC-Checksum and X-Recalculate-Hash is not supported -> sync must fail
isChecksumRecalculateSupported = false;
void testOctetsToString()
{
QLocale::setDefault(QLocale("en"));
- QCOMPARE(octetsToString(999) , QString("999 B"));
- QCOMPARE(octetsToString(1024) , QString("1 KB"));
- QCOMPARE(octetsToString(1110) , QString("1 KB"));
- QCOMPARE(octetsToString(1364) , QString("1 KB"));
-
- QCOMPARE(octetsToString(9110) , QString("9 KB"));
- QCOMPARE(octetsToString(9910) , QString("10 KB"));
- QCOMPARE(octetsToString(9999) , QString("10 KB"));
- QCOMPARE(octetsToString(10240) , QString("10 KB"));
-
- QCOMPARE(octetsToString(123456) , QString("121 KB"));
- QCOMPARE(octetsToString(1234567) , QString("1.2 MB"));
- QCOMPARE(octetsToString(12345678) , QString("12 MB"));
- QCOMPARE(octetsToString(123456789) , QString("118 MB"));
- QCOMPARE(octetsToString(1000LL*1000*1000 * 5) , QString("4.7 GB"));
-
- QCOMPARE(octetsToString(1), QString("1 B"));
- QCOMPARE(octetsToString(2), QString("2 B"));
- QCOMPARE(octetsToString(1024), QString("1 KB"));
- QCOMPARE(octetsToString(1024*1024), QString("1 MB"));
- QCOMPARE(octetsToString(1024LL*1024*1024), QString("1 GB"));
- QCOMPARE(octetsToString(1024LL*1024*1024*1024), QString("1 TB"));
- QCOMPARE(octetsToString(1024LL*1024*1024*1024 * 5), QString("5 TB"));
+ QCOMPARE(octetsToString(999) , QStringLiteral("999 B"));
+ QCOMPARE(octetsToString(1024) , QStringLiteral("1 KB"));
+ QCOMPARE(octetsToString(1110) , QStringLiteral("1 KB"));
+ QCOMPARE(octetsToString(1364) , QStringLiteral("1 KB"));
+
+ QCOMPARE(octetsToString(9110) , QStringLiteral("9 KB"));
+ QCOMPARE(octetsToString(9910) , QStringLiteral("10 KB"));
+ QCOMPARE(octetsToString(9999) , QStringLiteral("10 KB"));
+ QCOMPARE(octetsToString(10240) , QStringLiteral("10 KB"));
+
+ QCOMPARE(octetsToString(123456) , QStringLiteral("121 KB"));
+ QCOMPARE(octetsToString(1234567) , QStringLiteral("1.2 MB"));
+ QCOMPARE(octetsToString(12345678) , QStringLiteral("12 MB"));
+ QCOMPARE(octetsToString(123456789) , QStringLiteral("118 MB"));
+ QCOMPARE(octetsToString(1000LL*1000*1000 * 5) , QStringLiteral("4.7 GB"));
+
+ QCOMPARE(octetsToString(1), QStringLiteral("1 B"));
+ QCOMPARE(octetsToString(2), QStringLiteral("2 B"));
+ QCOMPARE(octetsToString(1024), QStringLiteral("1 KB"));
+ QCOMPARE(octetsToString(1024*1024), QStringLiteral("1 MB"));
+ QCOMPARE(octetsToString(1024LL*1024*1024), QStringLiteral("1 GB"));
+ QCOMPARE(octetsToString(1024LL*1024*1024*1024), QStringLiteral("1 TB"));
+ QCOMPARE(octetsToString(1024LL*1024*1024*1024 * 5), QStringLiteral("5 TB"));
}
void testLaunchOnStartup()
QDateTime current = QDateTime::currentDateTimeUtc();
- QCOMPARE(durationToDescriptiveString2(0), QString("0 second(s)") );
- QCOMPARE(durationToDescriptiveString2(5), QString("0 second(s)") );
- QCOMPARE(durationToDescriptiveString2(1000), QString("1 second(s)") );
- QCOMPARE(durationToDescriptiveString2(1005), QString("1 second(s)") );
- QCOMPARE(durationToDescriptiveString2(56123), QString("56 second(s)") );
- QCOMPARE(durationToDescriptiveString2(90*sec), QString("1 minute(s) 30 second(s)") );
- QCOMPARE(durationToDescriptiveString2(3*hour), QString("3 hour(s)") );
- QCOMPARE(durationToDescriptiveString2(3*hour + 20*sec), QString("3 hour(s)") );
- QCOMPARE(durationToDescriptiveString2(3*hour + 70*sec), QString("3 hour(s) 1 minute(s)") );
- QCOMPARE(durationToDescriptiveString2(3*hour + 100*sec), QString("3 hour(s) 2 minute(s)") );
+ QCOMPARE(durationToDescriptiveString2(0), QStringLiteral("0 second(s)") );
+ QCOMPARE(durationToDescriptiveString2(5), QStringLiteral("0 second(s)") );
+ QCOMPARE(durationToDescriptiveString2(1000), QStringLiteral("1 second(s)") );
+ QCOMPARE(durationToDescriptiveString2(1005), QStringLiteral("1 second(s)") );
+ QCOMPARE(durationToDescriptiveString2(56123), QStringLiteral("56 second(s)") );
+ QCOMPARE(durationToDescriptiveString2(90*sec), QStringLiteral("1 minute(s) 30 second(s)") );
+ QCOMPARE(durationToDescriptiveString2(3*hour), QStringLiteral("3 hour(s)") );
+ QCOMPARE(durationToDescriptiveString2(3*hour + 20*sec), QStringLiteral("3 hour(s)") );
+ QCOMPARE(durationToDescriptiveString2(3*hour + 70*sec), QStringLiteral("3 hour(s) 1 minute(s)") );
+ QCOMPARE(durationToDescriptiveString2(3*hour + 100*sec), QStringLiteral("3 hour(s) 2 minute(s)") );
QCOMPARE(durationToDescriptiveString2(current.msecsTo(current.addYears(4).addMonths(5).addDays(2).addSecs(23*60*60))),
- QString("4 year(s) 5 month(s)") );
+ QStringLiteral("4 year(s) 5 month(s)") );
QCOMPARE(durationToDescriptiveString2(current.msecsTo(current.addDays(2).addSecs(23*60*60))),
- QString("2 day(s) 23 hour(s)") );
-
- QCOMPARE(durationToDescriptiveString1(0), QString("0 second(s)") );
- QCOMPARE(durationToDescriptiveString1(5), QString("0 second(s)") );
- QCOMPARE(durationToDescriptiveString1(1000), QString("1 second(s)") );
- QCOMPARE(durationToDescriptiveString1(1005), QString("1 second(s)") );
- QCOMPARE(durationToDescriptiveString1(56123), QString("56 second(s)") );
- QCOMPARE(durationToDescriptiveString1(90*sec), QString("2 minute(s)") );
- QCOMPARE(durationToDescriptiveString1(3*hour), QString("3 hour(s)") );
- QCOMPARE(durationToDescriptiveString1(3*hour + 20*sec), QString("3 hour(s)") );
- QCOMPARE(durationToDescriptiveString1(3*hour + 70*sec), QString("3 hour(s)") );
- QCOMPARE(durationToDescriptiveString1(3*hour + 100*sec), QString("3 hour(s)") );
+ QStringLiteral("2 day(s) 23 hour(s)") );
+
+ QCOMPARE(durationToDescriptiveString1(0), QStringLiteral("0 second(s)") );
+ QCOMPARE(durationToDescriptiveString1(5), QStringLiteral("0 second(s)") );
+ QCOMPARE(durationToDescriptiveString1(1000), QStringLiteral("1 second(s)") );
+ QCOMPARE(durationToDescriptiveString1(1005), QStringLiteral("1 second(s)") );
+ QCOMPARE(durationToDescriptiveString1(56123), QStringLiteral("56 second(s)") );
+ QCOMPARE(durationToDescriptiveString1(90*sec), QStringLiteral("2 minute(s)") );
+ QCOMPARE(durationToDescriptiveString1(3*hour), QStringLiteral("3 hour(s)") );
+ QCOMPARE(durationToDescriptiveString1(3*hour + 20*sec), QStringLiteral("3 hour(s)") );
+ QCOMPARE(durationToDescriptiveString1(3*hour + 70*sec), QStringLiteral("3 hour(s)") );
+ QCOMPARE(durationToDescriptiveString1(3*hour + 100*sec), QStringLiteral("3 hour(s)") );
QCOMPARE(durationToDescriptiveString1(current.msecsTo(current.addYears(4).addMonths(5).addDays(2).addSecs(23*60*60))),
- QString("4 year(s)") );
+ QStringLiteral("4 year(s)") );
QCOMPARE(durationToDescriptiveString1(current.msecsTo(current.addDays(2).addSecs(23*60*60))),
- QString("3 day(s)") );
+ QStringLiteral("3 day(s)") );
}